


<?php
$this->breadcrumbs=array(
	'Suppliers',
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
    $('.search-form').slideToggle('fast');
    return false;
});
$('.search-form form').submit(function(){
    $.fn.yiiGridView.update('suppliers-grid', {
        data: $(this).serialize()
    });
    return false;
});
");

?>

<div class="col-xs-10">
<div class="page-content">
		<div class="page-header">

<h1>Suppliers</h1>
<hr />

<?php 
$this->beginWidget('zii.widgets.CPortlet', array(
	'htmlOptions'=>array(
		'class'=>''
	)
));
$this->widget('bootstrap.widgets.TbMenu', array(
	'type'=>'pills',
	'items'=>array(
		array('label'=>'Create', 'icon'=>'icon-plus', 'url'=>Yii::app()->controller->createUrl('create'), 'linkOptions'=>array()),
                array('label'=>'List', 'icon'=>'icon-th-list', 'url'=>Yii::app()->controller->createUrl('index'),'active'=>true, 'linkOptions'=>array()),
		array('label'=>'Search', 'icon'=>'icon-search', 'url'=>'#', 'linkOptions'=>array('class'=>'search-button')),
		array('label'=>'Export to PDF', 'icon'=>'icon-download', 'url'=>Yii::app()->controller->createUrl('GeneratePdf'), 'linkOptions'=>array('target'=>'_blank'), 'visible'=>true),
		array('label'=>'Export to Excel', 'icon'=>'icon-download', 'url'=>Yii::app()->controller->createUrl('GenerateExcel'), 'linkOptions'=>array('target'=>'_blank'), 'visible'=>true),
	),
));
$this->endWidget();
?>



<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->


<?php $this->widget('bootstrap.widgets.TbGridView',array(
	'id'=>'suppliers-grid',
	'dataProvider'=>$model->search(),
        'type'=>'striped bordered condensed',
        'template'=>'{summary}{pager}{items}{pager}',
	'columns'=>array(
		//'id',
		'name',
		'supplier_code',
		
		'phone_number',
		
		'fax',
		
		array(
			'header'=>'View',
			'value'=>'\'<a class="btn btn-small icon-user" data-original-title="Contacts Persons" rel="tooltip" data-target="#\'.$data->id.\'" data-toggle="modal"></a> <a class="btn btn-small icon-list-alt" data-original-title="QR History" rel="tooltip" data-target="#qr\'.$data->id.\'" data-toggle="modal"></a> <a class="btn btn-small icon-barcode" data-original-title="PO History" rel="tooltip" data-target="#po\'.$data->id.\'" data-toggle="modal"></a>\'',
			'type'=>'raw',
			'htmlOptions'=>array('style'=>'width: 145px'),
		),
		/*
		'address',
		'city',
		'post_code',
		
		'email',
		'website',
		'npwp',
		'attn',
		'cc',
		*/
       array(
            'class'=>'bootstrap.widgets.TbButtonColumn',
			'template' => '{view} {update}',
			'buttons' => array(
			      'view' => array(
					'label'=> 'View',
					'options'=>array(
						'class'=>'btn btn-small view'
					)
				),	
                              'update' => array(
					'label'=> 'Update',
					'options'=>array(
						'class'=>'btn btn-small update'
					)
				),
				
				
			),
            'htmlOptions'=>array('style'=>'width: 105px'),
           )
	),
)); ?>


<?php
foreach($supp as $sup):
?>

<?php $this->beginWidget('bootstrap.widgets.TbModal', array('id'=>$sup->id)); ?>
 
<div class="modal-header">
    <a class="close" data-dismiss="modal">&times;</a>
    <h4>Contact List</h4>
</div>
 
<div class="modal-body">
<?php $this->widget('bootstrap.widgets.TbGridView',array(
	'id'=>'suppliers-contact-grid'.$sup->id,
	'dataProvider'=>SupplierContacts::model()->search2($sup->supplier_code),
        'type'=>'striped bordered condensed',
        'template'=>'{summary}{items}{pager}',
	'columns'=>array(
			'name',
			'position',
			'phone',
			'handphone',
			'email',
	),
)); ?>
</div>
 
<div class="modal-footer">
    <?php $this->widget('bootstrap.widgets.TbButton', array(
        'label'=>'Close',
        'url'=>'#',
        'htmlOptions'=>array('data-dismiss'=>'modal'),
    )); ?>
</div>
 
<?php $this->endWidget(); ?>
<?php endforeach; ?>





<?php
foreach($supp as $sup):
?>

<?php $this->beginWidget('bootstrap.widgets.TbModal', array('id'=>'qr'.$sup->id)); ?>
 
<div class="modal-header">
    <a class="close" data-dismiss="modal">&times;</a>
    <h4>Quotation Request History</h4>
</div>
 
<div class="modal-body">
 <?php $this->widget('bootstrap.widgets.TbGridView',array(
	'id'=>'quotation-request-grid'.$sup->id,
	'dataProvider'=>QuotationRequest::model()->search2($sup->id),
        'type'=>'striped bordered condensed',
        'template'=>'{summary}{items}{pager}',
	'columns'=>array(
			'quotation_request_number',
			'trans_date',
			array(
				'name'=>'qty',
				'value'=>'QuotationRequestDetail::model()->find("id_quotation_request=".$data->id)->qty',
			),
			'status',
	),
)); ?>   
</div>
 
<div class="modal-footer">
    <?php $this->widget('bootstrap.widgets.TbButton', array(
        'label'=>'Close',
        'url'=>'#',
        'htmlOptions'=>array('data-dismiss'=>'modal'),
    )); ?>
</div>
 
<?php $this->endWidget(); ?>
<?php endforeach; ?>


<?php
foreach($supp as $sup):
?>

<?php $this->beginWidget('bootstrap.widgets.TbModal', array('id'=>'po'.$sup->id)); ?>
 
<div class="modal-header">
    <a class="close" data-dismiss="modal">&times;</a>
    <h4>Purchase Order History</h4>
</div>
 
<div class="modal-body">
 <?php $this->widget('bootstrap.widgets.TbGridView',array(
	'id'=>'quotation-request-grid'.$sup->id,
	'dataProvider'=>Po::model()->search2($sup->id),
        'type'=>'striped bordered condensed',
        'template'=>'{summary}{items}{pager}',
	'columns'=>array(
			'po_number',
			'po_date',
			array(
				'name'=>'qty',
				'value'=>'PoDetail::model()->find("po_number=\'".$data->po_number."\'")->qty',
			),
			'status',
	),
)); ?>   
</div>
 
<div class="modal-footer">
    <?php $this->widget('bootstrap.widgets.TbButton', array(
        'label'=>'Close',
        'url'=>'#',
        'htmlOptions'=>array('data-dismiss'=>'modal'),
    )); ?>
</div>
 
<?php $this->endWidget(); ?>
<?php endforeach; ?>
</div>
</div>
</div>
									